package lab02.test24;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Scanner;

/**
 * Created by V555 on 2017/11/2.
 */
public class Test1 {
    public static void main(String[] args) throws ParseException {
        String date1,date2;
        Scanner scanner=new Scanner(System.in);
        System.out.println("输入一个日期：");
        date1=scanner.nextLine();
        System.out.println("输入一个日期：");
        date2=scanner.nextLine();
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-mm-dd");
        Calendar calendar=Calendar.getInstance();
        calendar.setTime(sdf.parse(date1));
        long time1=calendar.getTimeInMillis();
        calendar.setTime(sdf.parse(date2));
        long time2=calendar.getTimeInMillis();
        System.out.println("两个日期相差"+(time1-time2)/(24*60*60*1000)+"天");

    }
}
